<script src="/socket.io/socket.io.js"></script>
<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script>
  var socket = io.connect('http://localhost:8080');
	
	socket.on("connect", function(data){

    socket.on("welcome",function(data){
      $('#welcome').html(data.welcome);
    });
		
	

	socket.on("msg", function(data){
		var msg = $('#all').val();
		$('#all').val( msg + "\n" + data.message);
		$('#message').val("");
	});


  });

	var chat_fn = function(){
		var msg = $('#message').val();
		socket.emit("send", {message: msg});
	};

</script>
<h1 id="welcome"></h1>
<textarea id="all" rows=20></textarea>
<br />
<label>Message:</label>
<input id="message" type="text" name="message" cols=120/>
<input id="chat_btn" type="button" value="chat" onclick="javascript:chat_fn()" />

